module nios2lab1(
        // Clock Input (50 MHz)
        input CLOCK_50,
        //  Push Buttons
        input [3:0] KEY,
        //  DPDT Switches 
        input [9:0] SW,
        //  7-SEG Displays
        output [6:0] HEX0, HEX1, HEX2, HEX3,
        //  LEDs
        output [7:0] LEDG, //  LED Green[7:0]
        output [9:0] LEDR, //  LED Red[9:0]
        //  GPIO Connections
        inout [35:0] GPIO_0, GPIO_1
    );

    //  set all inout ports to tri-state
    assign GPIO_0 = 36'hzzzzzzzzz;
    assign GPIO_1 = 36'hzzzzzzzzz;

    wire RST;
    assign RST = KEY[0];

    // Connect dip switches to red LEDS
    assign LEDR[9:0] = SW[9:0];

    wire [31:0] inport, outport;
    assign inport[12:10] = KEY[3:1];
    assign inport[9:0] = SW;
    assign inport[31:21] = 0;
    //assign outport = inport;

    // map to 7-segment displays, blank leading zeros
    wire [7:0] bctl;
    hex_7seg_blanking dsp3(outport[15:12],HEX3,bctl[3],bctl[4]);
    hex_7seg_blanking dsp2(outport[11:8] ,HEX2,bctl[4],bctl[5]);
    hex_7seg_blanking dsp1(outport[7:4] ,HEX1,bctl[5],bctl[6]);
    hex_7seg_blanking dsp0(outport[3:0] ,HEX0,bctl[6],bctl[7]);

    logic interrupcao;
    logic [1:0] endereco;
    logic write_s;
    logic read_s;
    logic [31:0] writedata_s;
    logic chipselect_s;

    assign LEDG[0] = interrupcao;


    // instantiate our cpu 
  
    cpu1 cpu1_inst
    (
        .clk_0 (CLOCK_50),
        .reset_n (RST),
      
        .in_port_to_the_pio_0 (inport),
        .out_port_from_the_pio_0 (outport),
        .in_port_to_the_pio_1 (interrupcao),
      
	  
	  
        .address_out_sniffer_from_the_register_bank_0 (endereco),
        .write_out_sniffer_from_the_register_bank_0 (write_s),
        .read_out_sniffer_from_the_register_bank_0 (read_s),
        .writedata_out_sniffer_from_the_register_bank_0 (writedata_s),
        .chipselect_out_sniffer_from_the_register_bank_0 (chipselect_s),
      
        .aut_int_from_the_automato_esqueleto_0 (interrupcao),
        .dado_sniffer_to_the_automato_esqueleto_0 (writedata_s),
        .endereco_sniffer_to_the_automato_esqueleto_0 ({{(30){1'b0}}, endereco}),
        .read_sniffer_to_the_automato_esqueleto_0 (read_s),
        .write_sniffer_to_the_automato_esqueleto_0 (write_s),
        .chipselect_sniffer_to_the_automato_esqueleto_0 (chipselect_s)
    );


endmodule